package gui;

import java.awt.BorderLayout;

import javax.swing.JApplet;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import controller.DBController;
import controller.FileController;
import controller.PlotController;

public class Frame extends JApplet {

	public void setSize(int width, int height) {

	}

	public Frame(int wid, int hei) throws UnsupportedLookAndFeelException {
		this.initialize(wid, hei);
	}

	public void initialize(int wid, int hei) {
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (Exception e) {
			e.printStackTrace();
		}
		this.getContentPane().setLayout(new BorderLayout());
		this.northPanel = new NorthPanel();
		this.bottomPanel = new JPanel();
		this.bottomPanel.setLayout(new BorderLayout());
		this.getContentPane().add(this.northPanel, BorderLayout.NORTH);
		this.getContentPane().add(this.bottomPanel, BorderLayout.CENTER);
		this.textEditorPanel = new TextEditorPanel();
		this.outlinePanel = new OutlinePanel();
		this.fileBrowsePanel = new FileBrowsePanel();
		this.consolePanel = new ConsolePanel();

		splitPane3 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false,
				this.textEditorPanel, this.outlinePanel);

		splitPane3.setDividerLocation(wid - 200);

		splitPane3.setOneTouchExpandable(false);
		splitPane3.setDividerSize(5);

		splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, false,
				this.splitPane3, this.consolePanel);

		splitPane2.setDividerLocation(hei - 200);
		splitPane2.setOneTouchExpandable(false);
		splitPane2.setDividerSize(5);

		splitPane1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false,
				this.fileBrowsePanel, this.splitPane2);

		splitPane1.setDividerLocation(100);
		splitPane1.setOneTouchExpandable(false);
		splitPane1.setDividerSize(5);
		this.bottomPanel.add(this.splitPane1, BorderLayout.CENTER);

		FileController.getInstance().setTextEditorPanel(textEditorPanel);
		FileController.getInstance().setConsolePanel(consolePanel);

		PlotController.getInstance().setTextEditorPanel(textEditorPanel);
		PlotController.getInstance().setConsolePanel(consolePanel);
		
		DBController.getInstance().setTextEditorPanel(textEditorPanel);
		DBController.getInstance().setConsolePanel(consolePanel);
	}

	private NorthPanel northPanel = null;
	private JPanel bottomPanel = null;
	private TextEditorPanel textEditorPanel = null;
	private FileBrowsePanel fileBrowsePanel = null;
	private OutlinePanel outlinePanel = null;
	private ConsolePanel consolePanel = null;
	private JSplitPane splitPane1 = null;
	private JSplitPane splitPane2 = null;
	private JSplitPane splitPane3 = null;

}
